a11y: Protect should_present() from empty contexts
authorEmmanuele Bassi <ebassi@gnome.org>
Wed, 11 Nov 2020 18:09:43 +0000 (18:09 +0000)
committerEmmanuele Bassi <ebassi@gnome.org>
Wed, 11 Nov 2020 18:33:15 +0000 (18:33 +0000)
If the GtkAccessible implementation returns a NULL context, we should
not be calling methods on it.

gtk/gtkaccessible.c

index 13c4cb35edf4f5521ee4c86c9a3f6791c4b03194..e9f8d7d663696ee33ff3cd02635a885f730240bd 100644 (file)
@@ -678,9 +678,7 @@ gtk_accessible_platform_changed (GtkAccessible               *self,
 
   /* propagate changes up from ignored widgets */
   if (gtk_accessible_get_accessible_role (self) == GTK_ACCESSIBLE_ROLE_NONE)
-    {
-      context = gtk_accessible_get_at_context (GTK_ACCESSIBLE (gtk_widget_get_parent (GTK_WIDGET (self))));
-    }
+    context = gtk_accessible_get_at_context (GTK_ACCESSIBLE (gtk_widget_get_parent (GTK_WIDGET (self))));
 
   if (context == NULL)
     return;
@@ -765,6 +763,9 @@ gtk_accessible_should_present (GtkAccessible *self)
     return FALSE;
 
   context = gtk_accessible_get_at_context (self);
+  if (context == NULL)
+    return FALSE;
+
   if (gtk_at_context_has_accessible_state (context, GTK_ACCESSIBLE_STATE_HIDDEN))
     {
       GtkAccessibleValue *value;